<?php
/*
 * Created on 2012-3-5
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
class ContractAction extends CommonAction
{
	function _filter(& $map)
	{
		$map['sinceId'] = array (
			'like',
			"%" . $_POST['name'] . "%"
		);
	}
	//合同列表
	public function index()
	{
		$Contract = D("Contract");
		$Contract_list = $Contract->Select();
		$sumAmount = $Contract->sum('Amount');
		$this->assign('sumAmount', $sumAmount);
		//echo $Contract->getlastsql();
		//dump($Contract_list);
		$this->assign('list', $Contract_list);
		//		$this->display();
		parent :: index();
	}
	//合同添加
	public function add()
	{
		//查询合同类型
		$Contract_add = M('contract_type');
		$list = $Contract_add->select();
		$this->assign('contractType', $list);
		$Agentdb = M('Agent');
		$list = $Agentdb->select();
		$this->assign('agent', $list);
		$unitdb = M('unit');
		$list = $unitdb->select();
		$this->assign('units', $list);
		//		$this->display();
		parent :: add();
	}
	public function edit()
	{
		$Contract_add = M('contract_type');
		$list = $Contract_add->select();
		$this->assign('contractType', $list);
		$Agentdb = M('Agent');
		$list = $Agentdb->select();
		$this->assign('agent', $list);
		$unitdb = M('unit');
		$list = $unitdb->select();
		$this->assign('units', $list);
		//		$this->display();
		parent :: edit();
	}
	public function read()
	{
		$Contract_add = M('contract_type');
		$list = $Contract_add->select();
		$this->assign('contractType', $list);
		$Agentdb = M('Agent');
		$list = $Agentdb->select();
		$this->assign('agent', $list);
		$unitdb = M('unit');
		$list = $unitdb->select();
		$this->assign('units', $list);
		parent :: read();
	}
	//dump()
	//以下为测试之用
	function a()
	{

//		$q = strtolower($_GET["q"]);
//		if (!$q)
//			return;
//		$unit = M(unit);
//		$list = $unit->getField('id,unit_name');
//
//		$items = $list;
////dump($items);
//		foreach ($items as $key => $value)
//		{
//			if (strpos(strtolower($value), $q) !== false)
//			{
//				echo "$value|$key\n";
//			}
//		}

	} //a END
	//以上为测试之用
} //Contract END
?>
